package home.control.service;

import home.control.AlarmActivity;
import home.control.data.FactoryData;
import home.control.data.IGetData;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;

public class AlarmCheck extends Thread {
	
	private Activity activity;
	private static boolean stopThread = false;
	private IGetData connectData;
	private int i;
	
	public AlarmCheck(Activity a){
		this.activity = a;
		connectData = GetData.getInstance();
	}
	
	public void run() {
		while(stopThread){
			Log.d("Alarm","Petla watku: " + i++);
			if(connectData.getAlarm() == true){
				Log.d("Alarmm", "Jest alarm włacozny"); 
				Intent i = new Intent(activity, AlarmActivity.class);
				activity.startActivity(i);
			}
			Log.d("Alarmm", "Jest alarm wyłacozny"); 
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				Log.d("Alarm","Sleep sie nie udal");
				e.printStackTrace();
			}
		}
	}
	
	public static void stopThread(){
		stopThread = true;
	}
}
